<?php
namespace Qiaoxi\Model;
use Think\Model;
class UserModel extends Model {
	private $denyUsernames=array(
		'admin',
		'administrator'
	);
	
	public $_validate=array(
		array('username','require','username not null'),
		array('password','require','pswd not null',1,'',1),
		array('username','','用户名已经 存在',0,'unique',1),
		array('password','6,20','密码长度必须在6-20',0,'length'),
		array('password','/^\w{6,20}$/','密码格式错误'),
		array('repassword','password','确认密码错误',0,'confirm'),
		array('username','checkUsername','用户名非法',0,'callback'),
	);
	
	public function checkUsername($username)
	{
		foreach($this->denyUsernames as $u)
		{
			if (strpos($username,$u)!==false)
				return false;
		}
		return true;
	}
	
}